home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UTIL / MEMORY / VIRTUASRC / !Virtual / h / virtual < prev    next >
Text File  |  1993-09-06  |  5KB  |  142 lines

  1. /*
  2.  * virtual.h
  3.  * Part of the !Virtual distribution
  4.  * (c) bdb/nas/fo, 1992-3
  5.  */
  6.  
  7. /* Terminology:
  8.  * Place - addresses in memory, counted in pagesize, offset by 32K OS workspace
  9.  * Page - index into newpages array of pages we can use
  10.  * Slot - place in file where we can put something
  11.  */
  12.  
  13. /* Values stored in ourmem for each place: tag+value */
  14. #define TAG(x) ((x)>>28)
  15. #define LOC(x) ((x)&0xFFFFFFF)
  16. #define TAGLOC(x, y) (((x)<<28)+y)
  17.  
  18. #define DIRTY   0       /* written      LOC=page */
  19. #define SAVED   1       /* read only    LOC=slot, index[slot]=page */
  20. #define PAGED   2       /* paged out    LOC=slot, index[slot]=place */
  21. #define LOSE    3       /* page is candidate for paging out, but still there */
  22. #define ZERO    4       /* Zero fill this page when hit */
  23. #define ABORT   5       /* Error to hit this page */
  24.  
  25. #define ADDR(n) ((n)<<w->pageshift)
  26. #define PLACE(n) ((n)>>w->pageshift)
  27. #define SHUFT(n) ((n)%w->pagesize)
  28. #define REFT(n) (w->pagesize-SHUFT(n))
  29.  
  30. typedef struct PAGEENTRY
  31. {       int pagenum;
  32.         int addr;
  33.         int access;
  34. } PAGEENTRY;
  35.  
  36. #define ACCESS_READWRITE 0
  37. #define ACCESS_READONLY 1
  38. #define ACCESS_SVCONLY  2
  39. #define ACCESS_BAD      3
  40.  
  41. #define K32 (32*1024)
  42. #define M24 (24*1024*1024)
  43.  
  44. #define DUMPADDR ((31*1024+32)*1024)    /* dump pages here (where Wimp does) */
  45. #define LOCKADDRBIT 1           /* Set in newpages.addr during page in code */
  46.  
  47. /* per task workspace */
  48.  
  49. typedef struct private
  50. {
  51.         int uses;
  52.         struct WKSP *w; /* last touched w */
  53. } private;
  54.  
  55. typedef struct WKSP
  56. {
  57.         int regs[16];
  58. #define STACKSIZE 8000
  59.         char *stacktop;         /* stack to use to call C */
  60.         private *private;       /* link back to module private workspace */
  61.         int ourtask;            /* Us */
  62.  
  63.         int pagesize;           /* mem page size/bytes */
  64.         int numpages;           /* total # pages in system [hence size of oldpages/newpages] */
  65.         int pageshift;          /* log2 pagesize */
  66.  
  67.         int numplaces;          /* number of places in logical memory */
  68.         int *ourmem;            /* TAG+data for each place */
  69.  
  70.         int numourpages;        /* number of pages we have to play with (at start of newpages) */
  71.         PAGEENTRY *oldpages;    /* How pages found (0..numourpages were at 32K) */
  72.         PAGEENTRY *newpages;    /* New state we set up */
  73.         int losepage;           /* next page to swap out */
  74.  
  75.         char pagefilename[256];
  76.         int pagefile;           /* file handle we page to */
  77.         int nslots;             /* current number of slots in pagefile */
  78.         int *index;             /* data or -1 for each slot in pagefile */
  79.  
  80.         int OldPrefetchAbort;
  81.         int OldDataAbort;
  82.         int OldSWIV;
  83.         int OldCallBack;
  84.         int OldCallBackR12;
  85.         int OldCallBackRegs;
  86.  
  87.         int OldUpCall;
  88.         int OldUpCallR12;
  89.         int OldError;
  90.         int OldErrorR0;
  91.         int OldErrorBuf;
  92.         int OldExit;
  93.         int OldExitR12;
  94.  
  95.         int errPC;
  96.         int errnum;
  97.         char errmess[256];
  98.  
  99.         int outtask;            /* taskwindow server task */
  100.         int outblock[6];        /* used to build a wimp message around outbuf */
  101. #define OUTMAX (256-24)
  102.         char outbuf[OUTMAX];    /* output characters */
  103.         int outcount;           /* count */
  104. #define INSIZE 256
  105.         char inbuf[INSIZE];     /* circular input buffer */
  106.         int incount;            /* number in it */
  107.         int instart;            /* position of start */
  108.         int innbytes;           /* record of amount asked for in ramfetch */
  109.         int moreavailable;      /* flag that theres more to ramtransmit to us */
  110.         int EscapeChar;         /* character that causes escape */
  111.         int EscapeCharEnable;   /* enable above */
  112.  
  113.         char command[256];      /* command line read by OS_GetEnv */
  114.         char starttime[5];      /* App start time read by OS_GetEnv */
  115.         int MemoryLimit;
  116.         int UndefinedInstruction;
  117.         int PrefetchAbort;
  118.         int DataAbort;
  119.         int AddressException;
  120.         int OtherExceptions;
  121.         int Error,ErrorR0,ErrorBuf;
  122.         int CallBack,CallBackR12,CallBackBuf;
  123.         int BreakPoint,BreakPointR12,BreakPointBuf;
  124.         int Escape,EscapeR12;
  125.         int Event,EventR12;
  126.         int Exit,ExitR12;
  127.         int UnusedSWI,UnusedSWIR12;
  128.         int ExceptionRegs;
  129.         int ApplicationSpace;
  130.         int CurrentlyActiveObject;
  131.         int UpCall,UpCallR12;
  132.         int EscapeCondition;    /* 1 escape, 2 done handler */
  133.         int started_ingos;
  134.         int ingos;
  135.         int nice_run;           /* Running time for OS_CallEvery, cs */
  136.         int nice_delay;         /* Delay for Wimp_PollIdle, cs */
  137.         char *DDECL;
  138.         int DDECLSize;
  139.  
  140. } WKSP;
  141.  
  142.